
#include "ka-app/window-iOS.h"

using namespace ka;

iOSWindowDriver iOS_default_window_driver;

IWindowDriver *Window::getDefaultWindowDriver() {
    return &iOS_default_window_driver;
}

iOSWindowDriver::~iOSWindowDriver() {
    /*nothing*/
}

void *iOSWindowDriver::createWindowHandle() {
    CGRect mainBounds = [UIScreen mainScreen].bounds;
    UIWindow *uiWindow = [[UIWindow alloc] initWithFrame:mainBounds];
    return uiWindow;
}

void iOSWindowDriver::destroyWindowHandle(void *handle) {
    if (handle) {
        UIWindow *uiWindow = (UIWindow *)handle;
        [uiWindow release];
    }
}

void iOSWindowDriver::setWindowTitle(void *handle, const char *title) {
    /*nothing*/
    (void)handle;
    (void)title;
}

void iOSWindowDriver::showWindow(void *handle) {
    if (handle) {
        UIWindow *uiWindow = (UIWindow *)handle;
        [uiWindow makeKeyAndVisible];
    }
}